/*
 * @Author: '浪川' '1214391613@qq.com'
 * @Date: 2025-10-10 10:30:58
 * @LastEditors: '浪川' '1214391613@qq.com'
 * @LastEditTime: 2025-10-10 10:55:35
 * @FilePath: \book-3d-show\src\utils\BookBase.ts
 * @Description: 书籍的基础类
 */
import * as THREE from "three"
export class BookBase {
  book_group = new THREE.Group()
  width: number = 0
  height: number = 0
  depth: number = 0
  textureLoader: THREE.TextureLoader = new THREE.TextureLoader()
  constructor(width: number, height: number, depth: number) {
    this.width = width
    this.height = height
    this.depth = depth
  }
  get_image_file = (book_name: string, url: string) => {
    return new URL(`../assets/${book_name}/${url}.png`, import.meta.url).href
  }

  loadColorTexture(book_name: string, url: string) {
    const path = this.get_image_file(book_name, url)
    const texture = this.textureLoader.load(path)
    texture.colorSpace = THREE.SRGBColorSpace //设置为SRGB颜色空间

    return texture
  }
}
